package com.chinatsp.onlineapp.presenter;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import tsp.cn.http.BaseIDao;
import tsp.cn.http.HttpConfig;
import tsp.cn.http.interfac.INetResult;
import tsp.cn.http.tools.LogUtil;
import tsp.cn.http.tools.T;
import android.content.Context;

import com.chinatsp.onlineapp.base.Config;
import com.chinatsp.onlineapp.bean.LimitNum;
import com.google.gson.Gson;
/**
 * 尾号限行
 */
public class LimitNumDao extends BaseIDao {

	private LimitNum limitNum;
	private Context mContext;
    public LimitNumDao(Context context, INetResult iNetResult) {
        super(context, iNetResult);
        mContext = context;
    }

    /**
     * 数据
     */
    public LimitNum getLimitNum(){
    	return limitNum;
    }
    /**
     * 得到结果，对结果进行处理
     *
     * @param result
     * @param requestCode
     */
    @Override
    public void onRequestSuccess(String result, int requestCode) {

		LogUtil.d( "LimitNumDao onRequestSuccess");
    	limitNum = new Gson().fromJson(result, LimitNum.class);
    }

    /**
     * 获取限号
     */
    public void getLimitNum(String city) {

        StringBuilder strBuilder = new StringBuilder();
//        strBuilder.append(HttpConfig.appendString());
        
        /**
         * 测试用
         */
        //=======================
        //strBuilder.append(HttpConfig.IP);
       // strBuilder.append("100");
        //strBuilder.append("/1.0/tu/");
        //strBuilder.append("1/");
        //=======================
    	strBuilder.append(HttpConfig.appendString());
        strBuilder.append(Config.API_LIMIT_NUM);
        try {
            strBuilder.append(URLEncoder.encode(city, "utf-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        strBuilder.append("/");
        getRequest(strBuilder.toString(), Config.CODE_GET_HOT_CITY);
    }
}
